<%@ page import="java.util.List" %>
<%@ page isErrorPage="true"%>
<%@ page import="com.po.Envelope" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    HttpSession session1 = request.getSession(false);
    if (session1 == null || session1.getAttribute("id") == null) {
        response.sendRedirect(request.getContextPath() + "/index.jsp");
    }
%>
<table>
    <tr>
        <td>信封名字</td>
        <td>信封状态</td>
        <td>修改名字</td>
        <td>状态修改</td>
        <td>获赞总数</td>
        <td>信封创建的时间</td>
    </tr>
    <%
        List<Envelope> envelopes = (List<Envelope>) request.getAttribute("envelopes");
        if (!envelopes.isEmpty()) {
            for (Envelope envelope : envelopes) {
    %>
    <tr>
        <td><%=envelope.getName()%>
        </td>
        <td><%=envelope.getState()%>
        </td>
        <td>
            <button onclick="window.location.href='<%=request.getContextPath()%>/envelope/modifyEnvelopeName.jsp?envelope_id=<%=envelope.getEnvelope_id()%>'">修改</button>
        </td>
        <td>
            <button onclick="window.location.href='<%=request.getContextPath()%>/changeState?state=<%=envelope.getState()%>&envelope_id=<%=envelope.getEnvelope_id()%>';doChange()">更改</button>
        </td>
        <td>
            <%=envelope.getTotal_like()%>
        </td>
        <td><%=envelope.getCreate_time()%>
        </td>
        <td>
            <button onclick="window.location.href='<%=request.getContextPath()%>/function/selectNote?envelope_id=<%=envelope.getEnvelope_id()%>&envelope_name=<%=envelope.getName()%>'"
                    type="button">查看信封内容
            </button>

        </td>
    </tr>
    <%
            }
        }
    %>
</table>
<style>
    table {
        width: 600px;
        margin: auto;
        border: pink 1px solid;
        border-spacing: 0px;
        border-collapse: collapse;
    }

    td {
        border: pink 1px solid;
    }
    body{
        background-image: url("../picture/new.jpg");
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-position: center center;
        background-size: 100% 100%;
    }
</style>
<hr>
<a href="<%=request.getContextPath()%>/envelope/createEnvelope.jsp">添加信封</a>
<hr>
<a href="<%=request.getContextPath()%>/success.jsp">返回功能页面</a>
<script type="text/javascript">
    function doChange(){
        alert("修改成功");
    }
</script>
